package com.itheima.config;

import com.itheima.interceptors.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * 拦截器的配置，拦截什么，放行什么
 */
@Configuration
public class SpringMvcSupport extends WebMvcConfigurationSupport {

    @Autowired
    private TokenInterceptor tokenInterceptor;

    /**
     * 拦截器的配置 拦所有 放登录
     *
     * @param registry
     */
    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/employee/login")
                .excludePathPatterns("/dish/**").excludePathPatterns("/common/upload")
                .excludePathPatterns("/setmeal","/user/sendMsg","/user/login");
    }
}

